package org.acra.d;

import java.io.IOException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.acra.ACRA;
import org.acra.c.a;
import org.acra.sender.HttpSender.Method;
import org.acra.sender.HttpSender.Type;
import org.apache.http.HttpResponse;
import org.apache.http.StatusLine;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpEntityEnclosingRequestBase;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.methods.HttpPut;
import org.apache.http.conn.scheme.PlainSocketFactory;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
import org.apache.http.conn.ssl.SSLSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.auth.BasicScheme;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.impl.conn.tsccm.ThreadSafeClientConnManager;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.BasicHttpContext;
import org.apache.http.util.EntityUtils;

public final class c
{
  private String a;
  private String b;
  private int c = 3000;
  private int d = 3000;
  private int e = 3;

  public static String a(Map paramMap)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    Iterator localIterator = paramMap.keySet().iterator();
    while (localIterator.hasNext())
    {
      Object localObject1 = localIterator.next();
      if (localStringBuilder.length() != 0)
        localStringBuilder.append('&');
      Object localObject2 = paramMap.get(localObject1);
      if (localObject2 == null)
        localObject2 = "";
      localStringBuilder.append(URLEncoder.encode(localObject1.toString(), "UTF-8"));
      localStringBuilder.append('=');
      localStringBuilder.append(URLEncoder.encode(localObject2.toString(), "UTF-8"));
    }
    return localStringBuilder.toString();
  }

  private HttpClient a()
  {
    BasicHttpParams localBasicHttpParams = new BasicHttpParams();
    localBasicHttpParams.setParameter("http.protocol.cookie-policy", "rfc2109");
    HttpConnectionParams.setConnectionTimeout(localBasicHttpParams, this.c);
    HttpConnectionParams.setSoTimeout(localBasicHttpParams, this.d);
    HttpConnectionParams.setSocketBufferSize(localBasicHttpParams, 8192);
    SchemeRegistry localSchemeRegistry = new SchemeRegistry();
    localSchemeRegistry.register(new Scheme("http", new PlainSocketFactory(), 80));
    if (ACRA.getConfig().M())
      localSchemeRegistry.register(new Scheme("https", new b(), 443));
    while (true)
    {
      DefaultHttpClient localDefaultHttpClient = new DefaultHttpClient(new ThreadSafeClientConnManager(localBasicHttpParams, localSchemeRegistry), localBasicHttpParams);
      localDefaultHttpClient.setHttpRequestRetryHandler(new e(localBasicHttpParams, this.e, null));
      return localDefaultHttpClient;
      localSchemeRegistry.register(new Scheme("https", SSLSocketFactory.getSocketFactory(), 443));
    }
  }

  private UsernamePasswordCredentials b()
  {
    if ((this.a != null) || (this.b != null))
      return new UsernamePasswordCredentials(this.a, this.b);
    return null;
  }

  private HttpEntityEnclosingRequestBase b(URL paramURL, HttpSender.Method paramMethod, String paramString, HttpSender.Type paramType)
  {
    switch (d.a[paramMethod.ordinal()])
    {
    default:
      throw new UnsupportedOperationException("Unknown method: " + paramMethod.name());
    case 1:
    case 2:
    }
    for (Object localObject = new HttpPost(paramURL.toString()); ; localObject = new HttpPut(paramURL.toString()))
    {
      UsernamePasswordCredentials localUsernamePasswordCredentials = b();
      if (localUsernamePasswordCredentials != null)
        ((HttpEntityEnclosingRequestBase)localObject).addHeader(BasicScheme.authenticate(localUsernamePasswordCredentials, "UTF-8", false));
      ((HttpEntityEnclosingRequestBase)localObject).setHeader("User-Agent", "Android");
      ((HttpEntityEnclosingRequestBase)localObject).setHeader("Accept", "text/html,application/xml,application/json,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
      ((HttpEntityEnclosingRequestBase)localObject).setHeader("Content-Type", paramType.getContentType());
      ((HttpEntityEnclosingRequestBase)localObject).setEntity(new StringEntity(paramString, "UTF-8"));
      return localObject;
    }
  }

  public void a(int paramInt)
  {
    this.c = paramInt;
  }

  public void a(String paramString)
  {
    this.a = paramString;
  }

  public void a(URL paramURL, HttpSender.Method paramMethod, String paramString, HttpSender.Type paramType)
  {
    HttpClient localHttpClient = a();
    HttpEntityEnclosingRequestBase localHttpEntityEnclosingRequestBase = b(paramURL, paramMethod, paramString, paramType);
    ACRA.log.a(ACRA.LOG_TAG, "Sending request to " + paramURL);
    HttpResponse localHttpResponse = localHttpClient.execute(localHttpEntityEnclosingRequestBase, new BasicHttpContext());
    if (localHttpResponse != null)
    {
      if (localHttpResponse.getStatusLine() != null)
      {
        String str = Integer.toString(localHttpResponse.getStatusLine().getStatusCode());
        if ((str.startsWith("4")) || (str.startsWith("5")))
          throw new IOException("Host returned error code " + str);
      }
      EntityUtils.toString(localHttpResponse.getEntity());
    }
  }

  public void b(int paramInt)
  {
    this.d = paramInt;
  }

  public void b(String paramString)
  {
    this.b = paramString;
  }

  public void c(int paramInt)
  {
    this.e = paramInt;
  }
}

/* Location:           D:\Studium\Bachelorarbeit\BA Marcus Wobig\BA\BA\Decompiler\PicturePassword APK\Programm\PicturePassword_dex2jar.jar
 * Qualified Name:     org.acra.d.c
 * JD-Core Version:    0.6.2
 */